/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.blog.city.checkthedep.managedbeans;

import com.blog.city.checkthedep.entities.RegisteredUser;
import com.blog.city.checkthedep.sessionbeans.RegisteredUserFacadeLocal;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
/**
 *
 * @author Breath
 */
@ManagedBean
@RequestScoped
public class EditProfileBean {
    
    @ManagedProperty(value = "#{loginBean}")
    private LoginBean loginBean;
    
    private RegisteredUser editedUser = new RegisteredUser();
    @EJB
    private RegisteredUserFacadeLocal registeredFacade;
    
    /**
     * 
     * @return
     */
    public RegisteredUser getEditedUser() {
        return editedUser;
    }

    /**
     * 
     * @param editedUser
     */
    public void setEditedUser(RegisteredUser editedUser) {
        this.editedUser = editedUser;
    }

    /**
     * 
     * @return
     */
    public RegisteredUserFacadeLocal getRegisteredFacade() {
        return registeredFacade;
    }

    /**
     * 
     * @param registeredFacade
     */
    public void setRegisteredFacade(RegisteredUserFacadeLocal registeredFacade) {
        this.registeredFacade = registeredFacade;
    }

    /**
     * 
     * @return
     */
    public String persistEditedProfile() {
        editedUser=loginBean.getCheckedUser();
        if (editedUser != null) {
            registeredFacade.edit(editedUser);
        }
        return "showRegMenu";
    }

    /**
     * 
     * @return
     */
    public LoginBean getLoginBean() {
        return loginBean;
    }

    /**
     * 
     * @param loginBean
     */
    public void setLoginBean(LoginBean loginBean) {
        this.loginBean = loginBean;
    }
}
